/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "droit")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Droit.findAll", query = "SELECT d FROM Droit d"),
    @NamedQuery(name = "Droit.findByIddroit", query = "SELECT d FROM Droit d WHERE d.iddroit = :iddroit"),
    @NamedQuery(name = "Droit.findByNomdroit", query = "SELECT d FROM Droit d WHERE d.nomdroit = :nomdroit")})
public class Droit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "iddroit")
    private String iddroit;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nomdroit")
    private String nomdroit;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "droit")
    private Collection<PermissionUtilisateur> permissionUtilisateurCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "droit")
    private Collection<PermissionRole> permissionRoleCollection;

    public Droit() {
    }

    public Droit(String iddroit) {
        this.iddroit = iddroit;
    }

    public Droit(String iddroit, String nomdroit) {
        this.iddroit = iddroit;
        this.nomdroit = nomdroit;
    }

    public String getIddroit() {
        return iddroit;
    }

    public void setIddroit(String iddroit) {
        this.iddroit = iddroit;
    }

    public String getNomdroit() {
        return nomdroit;
    }

    public void setNomdroit(String nomdroit) {
        this.nomdroit = nomdroit;
    }

    @XmlTransient
    public Collection<PermissionUtilisateur> getPermissionUtilisateurCollection() {
        return permissionUtilisateurCollection;
    }

    public void setPermissionUtilisateurCollection(Collection<PermissionUtilisateur> permissionUtilisateurCollection) {
        this.permissionUtilisateurCollection = permissionUtilisateurCollection;
    }

    @XmlTransient
    public Collection<PermissionRole> getPermissionRoleCollection() {
        return permissionRoleCollection;
    }

    public void setPermissionRoleCollection(Collection<PermissionRole> permissionRoleCollection) {
        this.permissionRoleCollection = permissionRoleCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddroit != null ? iddroit.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Droit)) {
            return false;
        }
        Droit other = (Droit) object;
        if ((this.iddroit == null && other.iddroit != null) || (this.iddroit != null && !this.iddroit.equals(other.iddroit))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.Droit[ iddroit=" + iddroit + " ]";
    }
    
}
